<template>
  <div>
    <el-table
      :data="tableData"
      border
      stripe
      style="width: 100%">
      <!--      <el-table-column-->
      <!--        fixed-->
      <!--        prop="serialNumber"-->
      <!--        label="序号"-->
      <!--        width="150"/>-->
      <el-table-column
        prop="id"
        label="ID"
        width="120"/>
      <el-table-column
        prop="nickname"
        label="昵称"
        width="120"/>
      <el-table-column
        prop="gender"
        label="性别"
        width="120"/>
      <el-table-column
        prop="city"
        label="城市"
        />
      <el-table-column
        prop="marriage"
        label="账号状态"
        width="120"/>
      <el-table-column
        fixed="right"
        label="查看"
        width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleClick(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      :current-page="current"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getUserInfo"
    />
  </div>
</template>
<!--序号，ID，昵称，性别。城市。账号状态，操作-->
<script>
import user from '@/api/user'
export default {
  name: 'Index',
  data() {
    return {
      tableData: [],
      current: '1',
      limit: '10', // 每页显示数
      total: 0 //  总也是
    }
  },
  created() {
    this.getUserInfo()
    this.aaa()
  },
  methods: {
    getUserInfo(current = 1) {
      console.log(this.current, this.limit)
      this.current = current // 当前切换页码，重新赋值
      user.getUserInfoList(this.current, this.limit).then(res => {
        // this.tableData = [...this.tableData, ...res.items]
        this.tableData = res.items
        this.total = res.counts
      })
    },
    handleClick(row) {
      this.$router.push('/form/index/' + row.id)
    },
    aaa(){
       this.$router.push('/example/' + sessionStorage.getItem("username"))
    }
  }
}
</script>

<style scoped>

</style>
